<jsp:include page="header.jsp">
			<jsp:param value="item3" name="item"/>
</jsp:include> 
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<section class="content">
	<section class="widget"  id="department" >
		<header>
			<span class="icon">&#128196;</span>
			<hgroup>
				<h1>信息列表</h1>
				<h2>部门信息列表</h2>
			</hgroup>
		</header>
		<div class="content">
    <div class="tabs" id="tabs">
	    <ul>
	     	<li class="on">员工信息</li>
	        <li>出差记录</li>
	        <li>报销记录</li>
	        <li>兑换记录</li>
	        <li>部门报表</li>
	        <li>公司报表</li>
	    </ul>
	    <div id="userinfolist">
	    </div>
	    <div class="hide" id="travellist">
	    </div>
	    <div class="hide" id="applaylist">
	    </div>
	    <div class="hide" id="exchangelist">
	    </div>
	     <div class="hide" id="depreportlist">
	    </div>
	    <div class="hide" id="correportlist">
	    </div>

	</div>
</div>
</section>
<script type="text/javascript">
		var departments = [];
		var morq = "0";
		
		var count = 0;
		var  div = '#userinfolist';//div层的id
		var inputid = '#searcheuser';//输入框的id
		var subid = '#submit';//输入框的id
		var actionurl = "selectAction!getdepartments.action";//搜索框的服务器地址
		var liindex = 0; //用于搜索框监听回车跳转
		var divid = ["#userinfolist","#travellist","#applaylist","#exchangelist","#depreportlist","#correportlist"];
		
		window.onload = function(){
		   getinfodata(0);	//一开始加载页面。。。
			
           var oTab = document.getElementById("tabs");
           var oUl = oTab.getElementsByTagName("ul")[0];
           var oLis = oUl.getElementsByTagName("li");
           var oDivs= oTab.getElementsByTagName("div");

           for(var i= 0,len = oLis.length;i<len;i++){  
               oLis[i].index = i;
               oLis[i].onclick = function() {
                   for(var n= 0;n<len;n++){
                       oLis[n].className = "";
                       oDivs[n].className = "hide";//隐藏的类名
                       div = divid[n];	//div层赋值
	             	  $(div).attr("class","hide");
                   }
	               this.className = "on";//显示的类名
	               var index = this.index;
	               div = divid[index];	//div层赋值
	               $(div).attr("class","");
                   getinfodata(this.index);
               };
           }
        }
	
	function getinfodata(type,page){
			var $search = $(div);//取得div层id
			
		$.ajax( {
			url: "selectAction!selectDepreport.action",
			type: "get",
			data: {"type": type,"page": page,"departmentid": ($search.find("#departmentlist")).val()
			,"searchuserid": ($search.find("#searcheuser")).val(),"morq":($search.find("#morq")).val()},	//获取li的属性？可以传递的
			dataType: "json",
			contentType: "application/json",
			success: function(selectResult){
			 count = 0;
				showInfo(type,selectResult);	//这个也是
			},
			error: function(){
				alert("fail");
			}
	   });
	}
	
	function showInfo(index,selectResult){
		var data = eval("("+selectResult+")");
		var result="";
		var depid = data.depid;
		var searchuserid = data.searchuserid;
		
		//赋值给全局变量
			departments = data.departmentlist;
		if(data==null){
			alert('null');
			return ;
		}
		if(index=="0"){
				
				hocurr = data.pagenum;
				hopages = data.pages;
				div = '#userinfolist';//div层的id
				liindex = 0;
				 result+="<label>部门名称:</label>";
				result+="<select name='departmentlist' id='departmentlist' onchange='getinfodata(0)'>";
				result+="<option value=''>全部部门</option>";
				if(depid!=null){
				result+="<option value='"+depid+"' selected = 'selected'>"+data.dename+"</option>";
					for(var i=0;i<data.departmentlist.length;i++){
						if((data.departmentlist[i].departmentId)!=depid)
							result+="<option value='"+data.departmentlist[i].departmentId+"'>"+data.departmentlist[i].departmentName+"</option>";
					}
				}else{
					for(var i=0;i<data.departmentlist.length;i++){
							result+="<option value='"+data.departmentlist[i].departmentId+"'>"+data.departmentlist[i].departmentName+"</option>";
					}
				}
						
				result+="</select>";
				result+="<label for='searche'>员工号:</label>";
				if(searchuserid!=null&&searchuserid!="")
					result+="<input type='text' id='searcheuser' name='searcheuser'  onfocus='a()' value='"+searchuserid+"'/> ";	
				else
					result+="<input type='text' id='searcheuser' name='searcheuser' onfocus='a()' /> ";
				result+="<input type='submit' id='submit' class='button white' value='搜索' onclick='getinfodata(0)'/> ";
				
				
				
				
			if(data.userlist.length<1){
				result+="<h2>没有符合条件的员工记录</h2>";
			}else{
				
				result+="<table id='myTable'>";
				result+="<tr>";
				result+="<th>员工号</th>";
				result+="<th>用户名</th>";
				result+="<th>邮箱</th>";
				result+="<th>邮箱是否验证</th>";
				result+="<th>性别</th>";
				result+="<th>权限</th>";
				result+="<th>部门名称</th>";
				result+="<th>职位</th>";
				result+="<th>用户组</th>";
				result+="<th>点数</th>";
				result+="</tr>";
				for(var i=0;i<data.userlist.length;i++){
					result+="<tr>";
					result+="<td>"+data.userlist[i].userid+"</td>";
					result+="<td>"+data.userlist[i].userName+"</td>";
					
					result+="<td>"+data.userlist[i].email+"</td>";
					result+="<td>"+data.userlist[i].emailValidated+"</td>";
					result+="<td>"+data.userlist[i].gender+"</td>";
					result+="<td>"+data.userlist[i].authority+"</td>";
					result+="<td>"+data.userlist[i].department.departmentName+"</td>";
					result+="<td>"+data.userlist[i].position+"</td>";
					result+="<td>"+data.userlist[i].userGroup.userGroupName+"</td>";
					result+="<td>"+data.userlist[i].count+"</td>";
					result+="</tr>";
				}
				result+="</table>";
				result+="<div id='userinfopage' class='pagelist'>"+"</div>";
			}
			$("#userinfolist").html(result);
			
				laypage({
				cont: 'userinfopage',	//id
				pages: hopages,	//总页数
				curr: hocurr || 1,
				jump: function(obj,first){
					if(!first){
						getinfodata(0,obj.curr);
					}
				}
			});
			
		}else if(index=="1"){	
				
				hocurr = data.pagenum;
				hopages = data.pages;
				liindex = 1;
			   div = '#travellist';//div层的id
			   var depid = data.depid;
				var searchuserid = data.searchuserid;
				morq = data.morq;
				
				result+="<label>部门名称:</label>";
				result+="<select name='departmentlist' id='departmentlist' onchange='getinfodata(1)'>";
				result+="<option value=''>全部部门</option>";
				if(depid!=null){
				result+="<option value='"+depid+"' selected = 'selected'>"+data.dename+"</option>";
					for(var i=0;i<data.departmentlist.length;i++){
						if((data.departmentlist[i].departmentId)!=depid)
							result+="<option value='"+data.departmentlist[i].departmentId+"'>"+data.departmentlist[i].departmentName+"</option>";
					}
				}else{
					for(var i=0;i<data.departmentlist.length;i++){
							result+="<option value='"+data.departmentlist[i].departmentId+"'>"+data.departmentlist[i].departmentName+"</option>";
					}
				}
				result+="</select>";
				
				 result+="<label>状态:</label>";
				result+="<select name='morq' id='morq' onchange='getinfodata(1)'>";
				var status = ["全部状态","待审核","审核不通过","审核通过","待报销","已报销","报销不通过"];
				for(var i=0;i<status.length;i++){
					if(parseInt(morq)==i)
						result+="<option value='"+i+"' selected = 'selected'>"+status[i]+"</option>";
					else
						result+="<option value='"+i+"'>"+status[i]+"</option>";
				}
				result+="</select>";
				
				result+="<label for='searche'>员工号:</label>";
				if(searchuserid!=null&&searchuserid!="")
					result+="<input type='text' id='searcheuser' name='searcheuser'  onfocus='a()' value='"+searchuserid+"'/> ";	
				else
					result+="<input type='text' id='searcheuser' name='searcheuser' onfocus='a()' /> ";
				result+="<input type='submit' id='submit'  class='button white' value='搜索' onclick='getinfodata(1)'/> ";
				
			if(data.travellist.length<1){
				result+="<h2>没有符合条件的出差记录</h2>";
			}else{
				
				result+="<table id='myTable'>";
				result+="<tr>";
				result+="<th>出差单号</th>";
				result+="<th>部门名称</th>";
				result+="<th>员工号</th>";
				result+="<th>职工姓名</th>";
				result+="<th>开始时间</th>";
				result+="<th>结束时间</th>";
				result+="<th>总预算/元</th>";
				result+="<th>状态</th>";
				result+="<th>审批人</th>";
				result+="</tr>";
				for(var i=0;i<data.travellist.length;i++){
					result+="<tr>";
					 //日期转换
					var d = new Date(data.travellist[i].startTime.time);
					var date = d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
					var ed = new Date(data.travellist[i].endTime.time);
					var enddate = ed.getFullYear()+"-"+(ed.getMonth()+1)+"-"+ed.getDate();
					
					result+="<td>"+data.travellist[i].travelOrder+"</td>";
					if(depid!=null)
						result+="<td>"+data.dename+"</td>";
					else
						result+="<td>"+data.depidStrings[i]+"</td>";
					result+="<td>"+data.travellist[i].userInfoByUserid.userid+"</td>";
					result+="<td>"+data.travellist[i].userInfoByUserid.userName+"</td>";
					result+="<td>"+date+"</td>";
					result+="<td>"+enddate+"</td>";
					result+="<td>"+data.travellist[i].amount+"</td>";
					result+="<td>"+data.travellist[i].verifierStatus+"</td>";
					result+="<td>"+data.vernames[i]+"</td>";
					result+="</tr>";
				}
				result+="</table>";
				result+="<div id='travellistpage' class='pagelist'>"+"</div>";
			}
				$("#travellist").html(result);
				
				laypage({
				cont: 'travellistpage',	//id
				pages: hopages,	//总页数
				curr: hocurr || 1,
				jump: function(obj,first){
					if(!first){
						getinfodata(1,obj.curr);
					}
				}
			});
		}else if(index=="2"){
			
				hocurr = data.pagenum;
				hopages = data.pages;
				liindex = 2;
			   div = '#applaylist';//div层的id
			   var depid = data.depid;
				var searchuserid = data.searchuserid;
				 morq = data.morq;
				 
				 result+="<label>部门名称:</label>";
				result+="<select name='departmentlist' id='departmentlist' onchange='getinfodata(2)'>";
				result+="<option value=''>全部部门</option>";
				if(depid!=null){
				result+="<option value='"+depid+"' selected = 'selected'>"+data.dename+"</option>";
					for(var i=0;i<data.departmentlist.length;i++){
						if((data.departmentlist[i].departmentId)!=depid)
							result+="<option value='"+data.departmentlist[i].departmentId+"'>"+data.departmentlist[i].departmentName+"</option>";
					}
				}else{
					for(var i=0;i<data.departmentlist.length;i++){
							result+="<option value='"+data.departmentlist[i].departmentId+"'>"+data.departmentlist[i].departmentName+"</option>";
					}
				}
				result+="</select>";
				
					
				 result+="<label>状态:</label>";
				result+="<select name='morq' id='morq' onchange='getinfodata(2)'>";
				var status = ["全部状态","待报销","已报销","报销不通过"];
				for(var i=0;i<status.length;i++){
					if(parseInt(morq)==i)
						result+="<option value='"+i+"' selected = 'selected'>"+status[i]+"</option>";
					else
						result+="<option value='"+i+"'>"+status[i]+"</option>";
				}
				result+="</select>";
				
				result+="<label for='searche'>员工号:</label>";
				if(searchuserid!=null&&searchuserid!="")
					result+="<input type='text' id='searcheuser' name='searcheuser'  onfocus='a()' value='"+searchuserid+"'/> ";	
				else
					result+="<input type='text' id='searcheuser' name='searcheuser' onfocus='a()' /> ";
				result+="<input type='submit' id='submit' class='button white' value='搜索' onclick='getinfodata(2)'/> ";
				 
			if(data.applaylist.length<1){			
				result+="<h2>没有符合条件的报销记录</h2>";
			}else{
				result+="<h1>节省费用=总预算-实际报销费用</h1>";
				result+="<table id='myTable'>";
				result+="<tr>";
				result+="<th>报销单号</th>";
				result+="<th>报销时间</th>";
				result+="<th>部门名</th>";
				result+="<th>员工号</th>";
				result+="<th>职工名</th>";
				result+="<th>预算/元</th>";
				result+="<th>报销/元</th>";
				result+="<th>节省/元</th>";
				result+="<th>状态</th>";
				result+="<th>审批人</th>";
				result+="</tr>";
				for(var i=0;i<data.applaylist.length;i++){
					result+="<tr>";
					 //日期转换
					var d = new Date(data.applaylist[i].applayTime.time);
					var date = d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
					result+="<td>"+data.applaylist[i].travelOrder+"</td>";
					result+="<td>"+date+"</td>";
					if(depid!=null)
						result+="<td>"+data.dename+"</td>";
					else
						result+="<td>"+data.depidStrings[i]+"</td>";
					result+="<td>"+data.applaylist[i].userInfo.userid+"</td>";
					result+="<td>"+data.applaylist[i].userInfo.userName+"</td>";
					result+="<td>"+data.applaylist[i].amount+"</td>";
					result+="<td>"+data.applaylist[i].realAppAmount+"</td>";
					result+="<td>"+data.applaylist[i].saveCost+"</td>";
					result+="<td>"+data.applaylist[i].businessTravelList.verifierStatus+"</td>";
					result+="<td>"+data.appbuslist[i].userInfoByVerifierId.userName+"</td>";
					result+="</tr>";
				}
				result+="</table>";
				result+="<div id='applaylistpage' class='pagelist'>"+"</div>";
			}
			$("#applaylist").html(result);
			laypage({
				cont: 'applaylistpage',	//id
				pages: hopages,	//总页数
				curr: hocurr || 1,
				jump: function(obj,first){
					if(!first){
						getinfodata(2,obj.curr);
					}
				}
			});
		}else if(index=="3"){
		
				hocurr = data.pagenum;
				hopages = data.pages;
				liindex = 3;
				
				div = '#exchangelist';//div层的id
				var depid = data.depid;
				var searchuserid = data.searchuserid;
				 morq = data.morq;
				 
				 result+="<label>部门名称:</label>";
				result+="<select name='departmentlist' id='departmentlist' onchange='getinfodata(3)'>";
				result+="<option value=''>全部部门</option>";
				if(depid!=null){
				result+="<option value='"+depid+"' selected = 'selected'>"+data.dename+"</option>";
					for(var i=0;i<data.departmentlist.length;i++){
						if((data.departmentlist[i].departmentId)!=depid)
							result+="<option value='"+data.departmentlist[i].departmentId+"'>"+data.departmentlist[i].departmentName+"</option>";
					}
				}else{
					for(var i=0;i<data.departmentlist.length;i++){
							result+="<option value='"+data.departmentlist[i].departmentId+"'>"+data.departmentlist[i].departmentName+"</option>";
					}
				}	
				result+="</select>";
				
				 result+="<label>是否领取:</label>";
				result+="<select name='morq' id='morq' onchange='getinfodata(3)'>";
				if(morq=="0"){
					result+="<option value='0' selected = 'selected'>否</option>";
					result+="<option value='1'>是</option>";
				}else{
					result+="<option value='0'>否</option>";
					result+="<option value='1' selected = 'selected'>是</option>";
				}
				result+="</select>";
				
				result+="<label for='searche'>员工号:</label>";
				if(searchuserid!=null&&searchuserid!="")
					result+="<input type='text' id='searcheuser' name='searcheuser'  onfocus='a()' value='"+searchuserid+"'/> ";	
				else
					result+="<input type='text' id='searcheuser' name='searcheuser' onfocus='a()' /> ";
				result+="<input type='submit' id='submit' class='button white' value='搜索' onclick='getinfodata(3)'/> ";
				 
			if(data.exchangelist.length<1){
				result+="<h2>没有符合条件的交换记录</h2>";
			}else{
				
				result+="<table id='myTable'>";
				result+="<tr>";
				result+="<th>交换时间</th>";
				result+="<th>部门名</th>";
				result+="<th>员工号</th>";
				result+="<th>职工名</th>";
				result+="<th>礼品名</th>";
				result+="<th>价值/件</th>";
				result+="<th>礼品描述</th>";
				result+="<th>兑换数量</th>";
				result+="<th>花费点数</th>";
				result+="<th>是否领取</th>";
				result+="</tr>";
				for(var i=0;i<data.exchangelist.length;i++){
					result+="<tr>";
					 //日期转换
					var d = new Date(data.exchangelist[i].id.exchangeTime.time);
					var date = d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
					result+="<td>"+date+"</td>";
					if(depid!=null)
						result+="<td>"+data.dename+"</td>";
					else
						result+="<td>"+data.depidStrings[i]+"</td>";
					result+="<td>"+data.exchangelist[i].userInfo.userid+"</td>";
					result+="<td>"+data.exchangelist[i].userInfo.userName+"</td>";
					result+="<td>"+data.exchangelist[i].gift.giftName+"</td>";
					result+="<td>"+data.exchangelist[i].gift.giftValue+"</td>";
					result+="<td>"+data.exchangelist[i].gift.description+"</td>";
					result+="<td>"+data.exchangelist[i].number+"</td>";
					result+="<td>"+data.exchangelist[i].points+"</td>";
					result+="<td>"+data.exchangelist[i].exchangeStatus+"</td>";
					result+="</tr>";
				}
				result+="</table>";
				result+="<div id='exchangelistpage' class='pagelist'>"+"</div>";
			}
			$("#exchangelist").html(result);
			
			laypage({
				cont: 'exchangelistpage',	//id
				pages: hopages,	//总页数
				curr: hocurr || 1,
				jump: function(obj,first){
					if(!first){
						getinfodata(3,obj.curr);
					}
				}
			});
		}else if(index=="4"){
		
				hocurr = data.pagenum;
				hopages = data.pages;
				liindex = 4;
				div = '#depreportlist';//div层的id
				 morq = data.morq;
				 
			   var depid = data.depid;
				 var years = data.years;
				 
				 result+="<label>部门名称:</label>";
				result+="<select name='departmentlist' id='departmentlist' onchange='getinfodata(4)'>";
				result+="<option value=''>全部部门</option>";
				if(depid!=null){
				result+="<option value='"+depid+"' selected = 'selected'>"+data.dename+"</option>";
					for(var i=0;i<data.departmentlist.length;i++){
						if((data.departmentlist[i].departmentId)!=depid)
							result+="<option value='"+data.departmentlist[i].departmentId+"'>"+data.departmentlist[i].departmentName+"</option>";
					}
				}else{
					for(var i=0;i<data.departmentlist.length;i++){
							result+="<option value='"+data.departmentlist[i].departmentId+"'>"+data.departmentlist[i].departmentName+"</option>";
					}
				}
				result+="</select>";
				 
				 result+="<label>报表类型:</label>";
				result+="<select name='morq' id='morq' onchange='getinfodata(4)'>";
				if(morq=="0"){
					result+="<option value='0' selected = 'selected'>月报</option>";
					result+="<option value='1'>季报</option>";
				}else{
					result+="<option value='0'>月报</option>";
					result+="<option value='1' selected = 'selected'>季报</option>";
				}
				
				result+="</select>";
				
				result+="<label for='searche'>年份:</label>";
				if(years!=null&&years!="")
					result+="<input type='text' id='searcheuser' name='searcheuser'  onfocus='a()' value='"+years+"'/> ";	
				else
					result+="<input type='text' id='searcheuser' name='searcheuser' onfocus='a()' /> ";
				result+="<input type='submit' id='submit' class='button white' value='搜索' onclick='getinfodata(4)'/> ";
				
			if(data.depreportlist.length<1){
				result+="<h2>没有符合条件的部门报表</h2>";
			}else{
				
				result+="<table id='myTable'>";
				result+="<tr>";
				if(morq=="0"){
				 	result+="<th>部门月报</th>";
				 }else
				 {
				 	result+="<th>部门季报</th>";
				 }
				result+="<th>更新时间</th>";
				result+="<th>部门名</th>";
				result+="<th>总预算/元</th>";
				result+="<th>总报销/元</th>";
				result+="<th>总节省/元</th>";
				result+="</tr>";
				for(var i=0;i<data.depreportlist.length;i++){
					result+="<tr>";
					if(morq=="0"){
					 	result+="<td>"+data.depreportlist[i].id.months+"</td>";
					 }else
					 {
					 	result+="<td>"+data.depreportlist[i].id.quarters+"</td>";
					 }
					 //日期转换
					var d = new Date(data.depreportlist[i].alterDate.time);
					var date = d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
					result+="<td>"+date+"</td>";
					
					result+="<td>"+data.depreportlist[i].department.departmentName+"</td>";
					result+="<td>"+data.depreportlist[i].allPreAmount+"</td>";
					result+="<td>"+data.depreportlist[i].allAppAmount+"</td>";
					result+="<td>"+data.depreportlist[i].saveAmount+"</td>";
					result+="</tr>";
				}
				result+="</table>";
				result+="<div id='depreportlistpage' class='pagelist'>"+"</div>";
			}
			$("#depreportlist").html(result);
			laypage({
				cont: 'depreportlistpage',	//id
				pages: hopages,	//总页数
				curr: hocurr || 1,
				jump: function(obj,first){
					if(!first){
						getinfodata(4,obj.curr);
					}
				}
			});
		}else if(index=="5"){
				
				hocurr = data.pagenum;
				hopages = data.pages;
				liindex = 5;
				div = '#correportlist';//div层的id
				 morq = data.morq;
				 
				var years = data.years;
				 
				 result+="<label>报表类型:</label>";
				result+="<select name='morq' id='morq' onchange='getinfodata(5)'>";
				if(morq=="0"){
					result+="<option value='0' selected = 'selected'>月报</option>";
					result+="<option value='1'>季报</option>";
				}else{
					result+="<option value='0'>月报</option>";
					result+="<option value='1' selected = 'selected'>季报</option>";
				}
				result+="</select>";
				
				result+="<label for='searche'>年份:</label>";
				if(years!=null&&years!="")
					result+="<input type='text' id='searcheuser' name='searcheuser'  onfocus='a()' value='"+years+"'/> ";	
				else
					result+="<input type='text' id='searcheuser' name='searcheuser' onfocus='a()' /> ";
				result+="<input type='submit' id='submit' class='button white' value='搜索' onclick='getinfodata(5)'/> ";
				 
			if(data.correportlist.length<1){
				result+="<h2>没有符合条件的公司报表</h2>";
			}else{
				
				result+="<table id='myTable'>";
				result+="<tr>";
				if(morq=="0"){
				 	result+="<th>公司月报</th>";
				 }else
				 {
				 	result+="<th>公司季报</th>";
				 }
				result+="<th>更新时间</th>";
				result+="<th>总预算/元</th>";
				result+="<th>总报销/元</th>";
				result+="<th>总节省/元</th>";
				result+="</tr>";
				for(var i=0;i<data.correportlist.length;i++){
					result+="<tr>";
					if(morq=="0"){
					 	result+="<td>"+data.correportlist[i].months+"</td>";
					 }else
					 {
					 	result+="<td>"+data.correportlist[i].quarters+"</td>";
					 }
					 //日期转换
					var d = new Date(data.correportlist[i].alterDate.time);
					var date = d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
					result+="<td>"+date+"</td>";
					result+="<td>"+data.correportlist[i].allPreAmount+"</td>";
					result+="<td>"+data.correportlist[i].allAppAmount+"</td>";
					result+="<td>"+data.correportlist[i].saveAmount+"</td>";
					result+="</tr>";
				}
				result+="</table>";
				result+="<div id='correportlistpage' class='pagelist'>"+"</div>";
			}
			$("#correportlist").html(result);
				laypage({
				cont: 'correportlistpage',	//id
				pages: hopages,	//总页数
				curr: hocurr || 1,
				jump: function(obj,first){
					if(!first){
						getinfodata(5,obj.curr);
					}
				}
			});
		}
	}
	</script>
  <!--员工信息的员工号搜索框  -->
<script type="text/javascript">
//部门员工信息
 	function a() {
 	if(count==0){
		//取得div层
			var $search = $(div);
		//取得输入框JQuery对象
		var $searchInput = $search.find(inputid);
		var $submid = $search.find(subid);
	//	var $searchInput = $(inputid);
		//关闭浏览器提供给输入框的自动完成
		$searchInput.attr('autocomplete', 'off');
		//创建自动完成的下拉列表，用于显示服务器返回的数据,插入在搜索按钮的后面，等显示的时候再调整位置
			var $autocomplete = $('<p class="autocomplete"></p>').hide()
				.insertAfter($submid);
		//清空下拉列表的内容并且隐藏下拉列表区
		var clear = function() {
			$autocomplete.empty().hide();
		};
		//注册事件，当输入框失去焦点的时候清空下拉列表并隐藏
		$searchInput.blur(function() {
			setTimeout(clear, 500);
		});
		
		//下拉列表中高亮的项目的索引，当显示下拉列表项的时候，移动鼠标或者键盘的上下键就会移动高亮的项目，想百度搜索那样
		var selectedItem = null;
		//timeout的ID
		var timeoutid = null;
		//设置下拉项的高亮背景
		var setSelectedItem = function(item) {
			//更新索引变量
			selectedItem = item;
			//按上下键是循环显示的，小于0就置成最大的值，大于最大值就置成0
			if (selectedItem < 0) {
				selectedItem = $autocomplete.find('li').length - 1;
			} else if (selectedItem > $autocomplete.find('li').length - 1) {
				selectedItem = 0;
			}
			//首先移除其他列表项的高亮背景，然后再高亮当前索引的背景
			$autocomplete.find('li').removeClass('highlight').eq(selectedItem)
					.addClass('highlight');
		};
		var ajax_request = function() {
			//ajax服务端通信
			$.ajax({
				'url' : actionurl, //服务器的地址
				'data' : {'search-text' : $searchInput.val(),"departmentid": ($search.find("#departmentlist")).val()
				,"type":liindex,"morq":($search.find("#morq")).val()}, //参数
				'dataType' : 'json', //返回数据类型
				contentType: "application/json",
				'success' : function(useridResult) {
				var data = eval("("+useridResult+")");
					if (data.useridresult.length) {
						//遍历data，添加到自动完成区
						$.each(data.useridresult, function(index, term) {
							//创建li标签,添加到下拉列表中
							$('<li></li>').text(term).appendTo($autocomplete)
									.addClass('clickable').hover(
											function() {
												//下拉列表每一项的事件，鼠标移进去的操作
												$(this).siblings().removeClass(
														'highlight');
												$(this).addClass('highlight');
												selectedItem = index;
											},
											function() {
												//下拉列表每一项的事件，鼠标离开的操作
												$(this)
														.removeClass(
																'highlight');
												//当鼠标离开时索引置-1，当作标记
												selectedItem = -1;
											}).click(function() {
										//鼠标单击下拉列表的这一项的话，就将这一项的值添加到输入框中
										$searchInput.val(term);
										//清空并隐藏下拉列表
										$autocomplete.empty().hide();
									});
						});//事件注册完毕
						//设置下拉列表的位置，然后显示下拉列表
						var ypos = $searchInput.position().top;
						var xpos = $searchInput.position().left;
						$autocomplete.css('width', $searchInput.css('width'));
						$autocomplete.css({
							'position' : 'absolute',
							'left' : xpos + "px",
							'top' : (ypos+40) + "px"
						});
						setSelectedItem(0);
						//显示下拉列表
						$autocomplete.show();
					}
				}
			});
		};
		//注册事件，当输入框得到焦点时，显示下拉框
		$searchInput.focus(function() {
			//首先删除下拉列表中的信息
								$autocomplete.empty().hide();
								clearTimeout(timeoutid);
								timeoutid = setTimeout(ajax_request, 100);
		});
		//对输入框进行事件注册
		$searchInput
				.keyup(
						function(event) {
							//字母数字，退格，空格
							if (event.keyCode > 40 || event.keyCode == 8
									|| event.keyCode == 32) {
								//首先删除下拉列表中的信息
								$autocomplete.empty().hide();
								clearTimeout(timeoutid);
								timeoutid = setTimeout(ajax_request, 100);
							} else if (event.keyCode == 38) {
								//上
								//selectedItem = -1 代表鼠标离开
								if (selectedItem == -1) {
									setSelectedItem($autocomplete.find('li').length - 1);
								} else {
									//索引减1
									setSelectedItem(selectedItem - 1);
								}
								event.preventDefault();
							} else if (event.keyCode == 40) {
								//下
								//selectedItem = -1 代表鼠标离开
								if (selectedItem == -1) {
									setSelectedItem(0);
								} else {
									//索引加1
									setSelectedItem(selectedItem + 1);
								}
								event.preventDefault();
							}
						}).keypress(
						function(event) {
							//enter键
							if (event.keyCode == 13) {
								//列表为空或者鼠标离开导致当前没有索引值
								if ($autocomplete.find('li').length == 0
										|| selectedItem == -1) {
									getinfodata(liindex);
								}
								$searchInput.val($autocomplete.find('li').eq(
										selectedItem).text());
								$autocomplete.empty().hide();
								event.preventDefault();
							}
						}).keydown(function(event) {
					//esc键
					if (event.keyCode == 27) {
						$autocomplete.empty().hide();
						event.preventDefault();
					}
					if (event.keyCode == 13) {
						//列表为空或者鼠标离开导致当前没有索引值
								if ($autocomplete.find('li').length == 0
										|| selectedItem == -1) {
									return ;
								}
								$searchInput.val($autocomplete.find('li').eq(
										selectedItem).text());
						$autocomplete.empty().hide();
						event.preventDefault();
						getinfodata(liindex);
					}
				});
		//注册窗口大小改变的事件，重新调整下拉列表的位置
		$(window).resize(function() {
			var ypos = $searchInput.position().top;
			var xpos = $searchInput.position().left;
			$autocomplete.css('width', $searchInput.css('width'));
			$autocomplete.css({
				'position' : 'relative',
				'left' : xpos + "px",
				'top' : ypos + "px"
			});
		});
		}
		count++;
	};
</script>
<%@ include file="footer.jsp" %>
